package tabdulin.sms.megafon;

import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;

/**
 * @author Talgat Abdulin
 *
 */
public class MegafonCaptchaSeeker extends HTMLEditorKit.ParserCallback {
	private String captchaID;
	
	public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet attributes, int position) {
		if (tag != HTML.Tag.INPUT) {
			return;
		}
		if (attributes.getAttributeCount() == 0) {
			return;
		}
		String name = (String) attributes.getAttribute(HTML.Attribute.NAME);
		if (name == null){
			return;
		}
		if (name.compareTo("codekey") != 0) {
			return;
		}
		this.captchaID = (String) attributes.getAttribute(HTML.Attribute.VALUE);
	}

	public String getCaptchaID() {
		return captchaID;
	}
}
